package hu;

import java.util.Scanner;

public class hu2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String ch = sc.nextLine();
        char c = ch.charAt(0);
        if(c <= 'Z' && c >= 'A')
            c = (char) (c + 32);
        int sum = 0;
        for (int i = 0; i < input.length(); i++) {
            char ch1 = input.charAt(i);
            if(input.charAt(i) >= 'A' && input.charAt(i) <= 'Z')
            {
                ch1 = (char) (ch1 + 32);
            }
            if(ch1 == c)
                sum++;
        }
        System.out.println(sum);

    }
}
/*
public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().toLowerCase();
        String ch = sc.nextLine().toLowerCase();
        char c = ch.charAt(0);
        int sum = 0;
        for (int i = 0; i < input.length(); i++) {
            char ch1 = input.charAt(i);
            if(ch1 == c)
                sum++;
        }
        System.out.println(sum);

    }
 */